package com.suep.data_analysis.repository;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.suep.data_analysis.model.DriveProperty;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DrivePropertyRepository extends BaseMapper<DriveProperty> {

    // 根据条件查询驱动盘属性
    @Select("SELECT * FROM t_drive_property WHERE ${ew.SQLSegment}")
    @Results({
            @Result(property = "propertyId", column = "property_id"),
            @Result(property = "setId", column = "set_id"),
            @Result(property = "position", column = "position"),
            @Result(property = "rarity", column = "rarity"),
            @Result(property = "mainStatType", column = "main_stat_type"),
            @Result(property = "subStats", column = "sub_stats", typeHandler = com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "updateTime", column = "update_time")
    })
    List<DriveProperty> selectDriveProperty(@Param("ew") Wrapper<DriveProperty> queryWrapper);

    // 根据套装ID查询驱动盘属性
    @Select("SELECT * FROM t_drive_property WHERE set_id = #{setId}")
    @Results({
            @Result(property = "propertyId", column = "property_id"),
            @Result(property = "setId", column = "set_id"),
            @Result(property = "position", column = "position"),
            @Result(property = "rarity", column = "rarity"),
            @Result(property = "mainStatType", column = "main_stat_type"),
            @Result(property = "subStats", column = "sub_stats", typeHandler = com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "updateTime", column = "update_time")
    })
    List<DriveProperty> selectBySetId(@Param("setId") String setId);
}